package com.fanshuai.soring.boot.config;


import com.fanshuai.soring.boot.webflux.metrics.ReactiveMetricsFilter;
import com.fanshuai.soring.boot.webflux.metrics.ReactiveMetricsHandlerAdapter;
import com.fanshuai.soring.boot.webflux.metrics.ReactiveMetricsHandlerMapping;
import com.fanshuai.soring.boot.webflux.metrics.ReactiveMetricsOutput;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;

public class ReactiveMetricsFilterConfig {

    @Bean
    public ReactiveMetricsFilter reactiveMetricsFilter() {
        return new ReactiveMetricsFilter();
    }

    @Bean
    public ReactiveMetricsOutput reactiveMetricsOutput() {
        return new ReactiveMetricsOutput();
    }

    @ConditionalOnBean(ReactiveMetricsOutput.class)
    @Bean
    public ReactiveMetricsHandlerMapping reactiveMetricsHandlerMapping(ReactiveMetricsOutput reactiveMetricsOutput) {
        return new ReactiveMetricsHandlerMapping(reactiveMetricsOutput);
    }

    @Bean
    public ReactiveMetricsHandlerAdapter reactiveMetricsHandlerAdapter() {
        return new ReactiveMetricsHandlerAdapter();
    }
}
